package com.cloud.api.system.fallBack;

import com.cloud.api.system.SystemTestFeign;
import com.cloud.common.core.model.response.SuccessResponses;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class SystemTestFeignFallbackFactory implements FallbackFactory<SystemTestFeign> {

    @Override
    public SystemTestFeign create(Throwable throwable) {
        log.error("服务调用异常", throwable);
        return new SystemTestFeign() {
            @Override
            public SuccessResponses<String> sysLoad() {
                System.out.println("降级");
                return new SuccessResponses<>(200, "调用异常");
            }
        };
    }
}